%@ Language="VBScript" %> <% server.ScriptTimeout =56400 Session("NextURL") = "" Dim SubTotal, SubTotal2 Dim dictCart ' as dictionary Dim sAction ' as string Dim sKey ' as string Dim sItem ' as string Dim DiscQty 'discount qty Set rs = Server.CreateObject ("ADODB.RecordSet") Set rs99 = Server.CreateObject ("ADODB.RecordSet") Set conn = Server.CreateObject("ADODB.Connection") conn.Open DBConn 'create an cart object in the session If IsObject(Session("Cart")) Then Set dictCart = Session("cart") 'use session object Else Set dictCart = Server.CreateObject("Scripting.Dictionary") 'create new cart object End If sAction = CStr(Request("Action")) SubTotal2 = 0 'Application.Lock If sAction <> "" Then If sAction = "add" Then ItemCode = killChars(Request.Form("ItemCode")) ItemCode = ItemCode & Left(killChars(Request.Form("select_length")),2) Qty = killChars(Request.Form("choose_qty")) If ItemCode <> "" Then 'add qty if same item For Each Key In dictCart aryProd = Split(dictCart(Key), "|") 'assign product info into aryProd array If Trim(aryProd(0)) = ItemCode And Qty <> "" Then If sAction = "add" Then Qty = Int(aryProd(1)) + Int(Qty) End If dictCart.Remove Key End If Next If Int(Qty) < 0 Then Qty = 0 sItem = ItemCode & "|" & Qty If Qty <> "0" And Qty <> "" Then Randomize sKey = CStr(Rnd) 'generate a unique key to add 'dictCart.Add sKey, sItem On Error Resume Next dictCart.add sKey, sItem while err.number <> 0 Randomize sKey = CStr(Rnd) err.Clear dictCart.add sKey, sItem wend On Error goto 0 End If End If ElseIf sAction = "checkout" Then ItemCodes = killChars(Request("ItemCode")) Qtys = Request("Qty") aryItemCode = Split (ItemCodes, ",") aryQty = Split (Qtys, ",") dictCart.RemoveAll For i = 0 To UBound(aryItemCode) If trim(aryItemCode(i)) <> "" Then Qty = trim(aryQty(i)) If Int(Qty) < 0 Then Qty = 0 sItem = trim(aryItemCode(i)) & "|" & Qty If Qty <> "0" And Qty <> "" Then Randomize sKey = CStr(Rnd) 'generate a unique key to add 'dictCart.Add sKey, sItem On Error Resume Next dictCart.add sKey, sItem while err.number <> 0 Randomize sKey = CStr(Rnd) err.Clear dictCart.add sKey, sItem wend On Error goto 0 End If End If Next ElseIf sAction = "del" Then sKey = CStr(Request ("KeyID")) 'otherwise use existing key to delete dictCart.Remove sKey ElseIf sAction = "clear" Then dictCart.RemoveAll set Session("Cart")= nothing End If Set Session("cart") = dictCart End If if sAction = "checkout" then If Session("CustID") <> 0 Then Response.Redirect SecureURL & "/checkout1.asp" Else Session("NextURL") = SecureURL & "/checkout1.asp" Response.Redirect SecureURL & "/login.asp" End If end if %>
<%=SuccInfo%> |